<template>
	<view class="container">
		<view class="top_part">
			<image src="../../static/img/company/companyLogo.png" mode="" class="person_img"></image>
			<view class="top_name">
				企业认证
			</view>
			<image src="../../static/img/card1.png" mode="" class="card_img"></image>
		</view>
		<Blank></Blank>
		<view class="upload_part">
			<view class="title">
				便于审核通过，请务必提供清晰营业执照,保持人证为同一人.
			</view>
			<view class="code_part">
				<view class="left">
					<view class="name">
						示例照片
					</view>
					<view class="register_code">
						注册号或统一社会信用代码
					</view>
					<image src="../../static/img/company/code1.png" mode="" class="ex_img"></image>
				</view>
				<view class="right">
					<view class="name">
						上传照片
					</view>
					<view class="register_code">
						注册号或统一社会信用代码
					</view>
					<image @click="companyupload()" :src="form.companyImg?  form.companyImg:'../../static/img/company/code2.png'" mode="" class="ex_img"></image>
				</view>
			</view>
		</view>
		<Blank></Blank>
		<view class="info_part">
			<view class="info_name">
				法人代表
			</view>
			<input  v-model="form.name" class="uni-input" placeholder="请输入法人名称" placeholder-style="color:#A4A4A4;font-size:28rpx"/>
		</view>
		<view class="info_part">
			<view class="info_name">
				法人身份证
			</view>
			<input v-model="form.card" class="uni-input" placeholder="请输入法人身份证号" placeholder-style="color:#A4A4A4;font-size:28rpx"/>
		</view>
		<view class="info_part">
			<view class="info_name">
				手机号码
			</view>
			<input v-model="form.phone" class="uni-input" placeholder="请输入法人手机号" placeholder-style="color:#A4A4A4;font-size:28rpx"/>
		</view>
		<Blank></Blank>
		<view class="upload_card_part">
			<view class="upload_card">
				<view class="upload_card_name">
					示例照片
				</view>
				<image src="../../static/img/card2.png" mode="" class="example_img"></image>
				<view>上传照片</view>
				<image @click="beforeupload()" :src="form.beforeImg?  form.beforeImg:'../../static/img/card.png'" mode="" class="real_img"></image>
			</view>
			<view class="upload_card">
				<view class="upload_card_name">
					示例照片
				</view>
				<image src="../../static/img/card3.png" mode="" class="example_img"></image>
				<view>上传照片</view>
				<image @click="afterupload()" :src="form.afterImg?  form.afterImg:'../../static/img/card.png'" mode="" class="real_img"></image>
			</view>
		</view>
		
				<Blank></Blank>	
		<HandleBtn btnName="确认提交"  @click.native="submit()" class="btn"></HandleBtn>
		<view class="desc">
			认证信息会经过加密处理，仅供审核使用，别人无法看到。
		</view>
		
		
	</view>
</template>

<script>
	import Blank from "../../components/blank.vue"
	import HandleBtn from"../../components/handleBtn.vue"
	export default {
		components:{
			Blank,
			HandleBtn
		},
		data() {
			return {
				form:{
					name:"",
					phone:"",
					card:"",
					beforeImg:"",
					afterImg:"",
					companyImg:"",
					type:2
				}
			}
		},
		methods: {
			submit(){
				this.$utils.requert({url:'identity',data:this.form,type:'post'}).then(res=>{
						if(res.code === 1 ){
							this.$utils.showLayer(res.message)
							uni.navigateTo({
								url:'/pages/Companyinfo/Companyinfo',
							})
						}else{  
							this.$utils.showLayer(res.message)
						}
					})
			},
			//上传图片
			beforeupload(){
				   uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album','camera'], //从相册选择
					success: res=> {
						const file = res.tempFilePaths[0]
						const  token  = uni.getStorageSync('token')
						uni.uploadFile({
							url: this.$utils.domain+'/api/api/uploadImg', //仅为示例，非真实的接口地址
							filePath: file,
							name: 'file',
							header:{
								'accessToken':token
							},
							formData: {
								'type': '1'
							},
							success: (res) => {
								var res = JSON.parse(res.data)
								this.form.beforeImg = res.data.src
							}
						});
					},
					error : function(e){
					 // console.log(e);
					}
				  });
			},
			afterupload(){
				   uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album','camera'], //从相册选择
					success: res=> {
						const file = res.tempFilePaths[0]
						const  token  = uni.getStorageSync('token')
						uni.uploadFile({
							url: this.$utils.domain+'/api/api/uploadImg', //仅为示例，非真实的接口地址
							filePath: file,
							name: 'file',
							header:{
								'accessToken':token
							},
							formData: {
								'type': '1'
							},
							success: (res) => {
								var res = JSON.parse(res.data)
								this.form.afterImg = res.data.src
							}
						});
					},
					error : function(e){
					 // console.log(e);
					}
				  });
			},
			companyupload(){
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album','camera'], //从相册选择
					success: res=> {
						const file = res.tempFilePaths[0]
						const  token  = uni.getStorageSync('token')
						uni.uploadFile({
							url: this.$utils.domain+'/api/api/uploadImg', //仅为示例，非真实的接口地址
							filePath: file,
							name: 'file',
							header:{
								'accessToken':token
							},
							formData: {
								'type': '1'
							},
							success: (res) => {
								var res = JSON.parse(res.data)
								this.form.companyImg = res.data.src
							}
						});
					},
					error : function(e){
					 // console.log(e);
					}
				});
			}
		}
	}
</script>
<style>
	page {
		width: 100%;
		background-color: #fff;
	}
</style>

<style scoped>
	.container {
		width: 100%;
		padding-bottom: 70rpx;
	}
	.top_part{
		font-size: 24rpx;
		color:#FB8408;
		width:165rpx;
		margin:0 auto;
		padding:20rpx 0 14rpx;
		box-sizing: border-box;
		text-align: center;
	}
	.top_part .top_name{
		margin-bottom: -20rpx;
	}
	.top_part .person_img{
		width: 55rpx;
		height: 50rpx;
	}
	.top_part .card_img{
		width:115rpx;
		height: 9rpx;
	}
	.upload_part{
		padding:24rpx 32rpx 0 32rpx;
		box-sizing: border-box;
	}
	.upload_part .title{
		font-size: 24rpx;
		color:#A4A4A4;
		padding-bottom: 16rpx;
	}
	.upload_card{
		padding:28rpx 0;
		box-sizing: border-box;
		font-size: 22rpx;
		color:#2E2E2E;
		display: flex;
		align-items: center;
	}
	.upload_part .code_part {
		display: flex;
		justify-content: space-between;
	}
	.upload_part .code_part  .name{
		font-size: 22rpx;
		color:#2E2E2E;
		margin-bottom: 30rpx;
		margin-top: 20rpx;
	}
	.upload_part .code_part .register_code{
		font-size: 20rpx;
		color: #AEAEAE;
		width: 324rpx;
		height: 30rpx;
		text-align: center;
		line-height: 30rpx;
		border:1rpx solid #f6f6f6;
		border-radius: 3rpx;
		margin-bottom: 20rpx;
	}
	.upload_part .code_part .ex_img{
		width: 328rpx;
		height: 230rpx;
		margin-bottom: 20rpx;
	}
	
	.upload_card:nth-child(3){
		border-bottom: none;
	}
	.upload_card .upload_card_name{
		margin-right: 22rpx;
	}
	.upload_card .example_img{
		margin-right: 32rpx;
		width:186rpx;
		height: 128rpx;
	}
	.upload_card .real_img{
		width:200rpx;
		height: 144rpx;
	}
	.info_part{
		font-size: 28rpx;
		color:#333333;
		display: flex;
		align-items: center;
		margin:0 32rpx;
		padding:36rpx 0;
		box-sizing: border-box;
		border-bottom: 1rpx solid #f6f6f6;
	}
	.info_part:nth-child(3){
		border-bottom: none;
	}
	.info_part .info_name{
		margin-right: 40rpx;
	}
	.btn{
		margin-top: 63rpx;
		margin-bottom: 16rpx;
	}
	.desc{
		font-size: 24rpx;
		color: #7E7E7E;
		margin-bottom:50rpx;
		text-align: center;
	}
	.upload_card_part{
		margin:0 46rpx;
	}

</style>
